﻿@{
    Layout = null;
}
@using CNKI.TPI.Web.Search.Model;
<style>
    /*样式2——表头灰色渐变风格*/
    .table-grey th {
        color: #333;
        background-color: #f0f0f0;
        border: none;
    }

    .table-grey td {
        border: none;
        border-bottom: 1px dotted #bdbdbd;
    }

    /*摘要*/
    .abstract {
        font-family: '\5FAE\8F6F\96C5\9ED1';
    }

        .abstract li {
            border-bottom: 1px dotted #b7b7b7;
            padding-bottom: 5px;
            margin-bottom: 10px;
        }

        .abstract h2 {
            font-size: 14px;
            padding: 3px 0;
        }

        .works-info, .abstract p {
            font-size: 12px;
            margin-bottom: 5px;
        }

            .works-info span {
                margin-right: 50px;
            }

    .abstract-p span {
        font-weight: bold;
        color: #666;
    }

    .detail {
        font-family: '\5B8B\4F53';
        font-size: 12px;
    }

        .detail span {
            margin-right: 20px;
            color: #656565;
        }

    /*结果显示*/
    .order-r .lb {
        display: inline-block;
    }

        .order-r .lb a {
            display: inline-block;
            border: 1px solid #bebebe;
            padding: 1px 8px;
            margin-right: -4px;
        }

            .order-r .lb a i {
                color: #adadad;
            }

            .order-r .lb a:hover {
                color: #333;
            }

            .order-r .lb a.cur {
                color: #fff;
                background-color: #ff9330;
                border-color: #ff9330;
            }

                .order-r .lb a.cur i {
                    color: #fff;
                }

            .order-r .lb a i {
                margin-right: 3px;
            }

    .order-r span {
        color: #999;
        margin-left: 10px;
    }

    .order-r .next-t {
        display: inline-block;
        vertical-align: middle;
        margin-left: 10px;
        width: 20px;
        height: 20px;
        padding: 0;
        border: none;
        background: url(../images/sprite.png) no-repeat -1px -32px;
    }

        .order-r .next-t:hover {
            background-position: -2px -55px;
        }
    /*箭头样式*/
    .iconfontasc {
        display: inline-block;
        width: 10px;
        height: 16px;
        background: url(../images/iconfont-sprite.png) no-repeat;
        background-position: 0px -126px;
    }

        .iconfontasc:hover {
            background-position: -1px -160px;
        }

    .iconfontdesc {
        display: inline-block;
        vertical-align: middle;
        width: 10px;
        height: 16px;
        background: url(../images/iconfont-sprite.png) no-repeat;
        background-position: -1px -74px;
    }

        .cur .iconfontdesc, .iconfontdesc:hover {
            background-position: 0px -159px;
        }    
        
    /*图片库 视频库显示样式*/

    .e-book li {
        border-bottom: 1px dotted #dfdfdf;
        padding-bottom: 20px;
        margin-bottom: 26px;
        overflow: auto;
    }

    .e-book dl {
        width: 161px;
        float: left;
        font-family: '\5FAE\8F6F\96C5\9ED1';
        margin-right: 34px;
    }

    .e-book li dl.e-book-last {
        margin-right: 0;
    }

    .e-book dl input {
        float: none;
        margin: -2px 10px 0 0;
    }

    .e-book dl p {
        margin-bottom: 0;
        font-size: 12px;
    }

    .e-book img {
        border: 1px solid #dfdfdf;
        padding: 1px;
    }

    .pic-lib li {
        border: none;
        margin-bottom: 0;
    }

        .pic-lib li dl {
            width: 226px;
            border: 1px solid #dfdfdf;
            background: #f8f8f8;
            padding: 2px;
            margin-right: 8px;
        }

            .pic-lib li dl img {
                border: none;
            }

    .e-book-info {
        padding-left: 15px;
    }

    .pagenav span, .pagenav a:link, .pagenav a:visited {
        min-width: 24px;
        width: auto;
    }
</style>
<script type="text/javascript">

    function search() {
        $('#pageIndexNow').val('1');
        copyContion();//每次点击检索时将生效的查询条件存起来，避免点击分页或者列表，摘要模式时查询条件混乱
        searchResult();
    }
    //点击分页
    function searchPageNew(n) {
        $('#pageIndexNow').val(n);
        searchResult();
    }
    function searchResult() {

        $.ajax({
            type: "POST",
            url: timestamp("@Html.Raw(Url.Action("Search", "SingleSearch"))"),
            data: $("#formsubmit").serialize(),
            beforeSend: function () { $("#loading").show(); },
            success: function (msg) {
                $("#docList").html("");
                $("#docList").html(msg);
                hidetableth();
                $("#loading").hide();
            },
            error: function (e)
            { $("#loading").hide(); }
        })
    }
    ///隐藏下载按钮
    function hidetableth()
    {
        ;
        $("#table_list").find('th').each(function (thindex, thitem) { //遍历Table th  
            var headCaption = $(thitem).text();
            if (headCaption == "下载") {
            
                $(thitem).hide();
                $('#table_list tr').find('td:eq(' + thindex + ')').hide();
                var wth = $('#table_list th').eq(1).attr('width');
                wth = wth.substr(0, 2);
                wth = parseInt(wth) + 10;
                $('#table_list th').eq(1).attr('width', wth + '%');
               
            }  
        })
        $(".iconfont-down").hide();
    }
    function addCondition() {
        var subID = parseInt($('#currentSubid').val()) + 1;
        var len = document.getElementById("ConditionKey").options.length;
        if (subID < len) {
            var subDiv = $('#subCondition0');
            subDiv = subDiv.clone(true);
            subDiv.attr("style", "");
            subDiv.attr("id", "subCondition" + subID);
            var idstr = "SubConditionKey" + subID;
            subDiv.children("#SubConditionType0").attr("name", "SubConditionType" + subID);
            subDiv.children("#SubConditionType0").attr("id", "SubConditionType" + subID);
            subDiv.children("#SubConditionKey0").attr("name", idstr);
            subDiv.children("#SubConditionKey0").attr("id", idstr);

            subDiv.children("#SubConditionValue0").attr("name", "SubConditionValue" + subID);
            subDiv.children("#SubConditionValue0").attr("id", "SubConditionValue" + subID);

            subDiv.children("#SubConditionQuery0").attr("name", "SubConditionQuery" + subID);
            subDiv.children("#SubConditionQuery0").attr("id", "SubConditionQuery" + subID);
            $('#subCondition' + (subID - 1)).after(subDiv[0].outerHTML);
            $('#currentSubid').attr("value", subID);
            document.getElementById(idstr)[subID].selected = true; //选中项
            $("#SubConditionValue" + subID).attr("maxlength", 50);
        }
    }

    function delCondition() {

        var subID = parseInt($('#currentSubid').val());
        if (subID > 0) {
            $('#subCondition' + subID).remove();
            $('#currentSubid').attr("value", subID - 1);
        }
    }
    //复制原有查询条件
    function copyContion() {

        var select = $('#categoryType').val();
        var checkstr = "";
        if (typeof (myTree) != "undefined") {
            checkstr = myTree.getAllChecked();
        }
        $('#selectedCatTypeID').attr("value", select);
        if (checkstr != "" && checkstr != "0") {
            $('#checkedCatID').val(checkstr);
        }
        else {
            $('#checkedCatID').val("");
        }
        $("#beforecheckedCatID").val($("#checkedCatID").val());
        $("#beforeselectedCatTypeID").val($("#selectedCatTypeID").val());

        $("#beforeConditionValue").val($("#ConditionValue").val());
        $("#beforeConditionKey").val($("#ConditionKey").val());
        $("#beforeQueryValue").val($("#SubConditionQuery").val());

        var subID = parseInt($('#currentSubid').val());//获取当前条件数量
        if (subID > 0) {
            $("#beforeContion").html("");
            for (var i = 1; i <= subID; i++) {
                var beforeType = "beforeConditionType" + i;//新的id
                var conType = $('#' + 'SubConditionType' + i).val();//值
                $("#beforeContion").append("<input id=" + beforeType + " name=" + beforeType + " type=\"text\" value='" + conType + "' />");

                var beforeKey = "beforeConditionKey" + i;//新的id
                var conKey = $('#' + 'SubConditionKey' + i).val();//值
                $("#beforeContion").append("<input id=" + beforeKey + " name=" + beforeKey + " type=\"text\" value='" + conKey + "' />");

                var beforeValue = "beforeConditionValue" + i;//新的id
                var contValue = $('#' + 'SubConditionValue' + i).val();//值
                $("#beforeContion").append("<input id=" + beforeValue + " name=" + beforeValue + " type=\"text\" value='" + contValue + "' />");

                var beforeQuery = "beforeQueryValue" + i;//新的id
                var contQuery = $('#' + 'SubConditionQuery' + i).val();//值
                $("#beforeContion").append("<input id=" + beforeValue + " name=" + beforeQuery + " type=\"text\" value='" + contQuery + "' />");

            }

        }

    }
    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            search();
        }
    });
    //切换排序方式
    function sortClick(sort, ename) {
        $('#pageIndexNow').val('1');
        $("#sortField").val(ename);
        if (ename == $("#sortFieldBefore").val() || $("#sortFieldBefore").val() == "") { //如果是点击排序字段本身则调整排序顺序
            if (sort == "desc") {
                $('#sortDescAsc').val('asc');
            }
            else {
                $('#sortDescAsc').val('desc');
            }
        }
        else {  //如果是点击其他排序字段，则按数据库默认排序
            var initsort = $("#sortInit").val();
            $('#sortDescAsc').val(initsort);//数据库默认排序
            $("#sortFieldBefore").val(ename);
        }

        searchResult();
    }
    //切换显示模式
    function formatList(formatstr) {
        if (formatstr == "list") {
            $('#listOrabst').val('list');
        }
        else {
            $('#listOrabst').val('abct');
        }
        searchResult();

    }
    $(function () {
        setinfo();
    })
    function setinfo() {
        var thisdbid = $("#DbList").val();
        $("#dbID").val(thisdbid.toString().split("_")[0]);
        $("#dbName").val(thisdbid.toString().split("_")[1]); //数据库编码
        //;
        $("#DBDisplayName").val($("#DbList option:selected").text());
        deptobj = $("#ConditionKey");
        subconobj = $("#SubConditionKey0");

        //检索字段级联
        $.ajax({
            type: "GET",
            url: timestamp("@Html.Raw(Url.Action("GetDBSearchField", "Admin_Topic"))?dbID=" + thisdbid.toString().split("_")[0]),
            success: function (obj) {
                if (obj != null && obj.length > 0) {
                    deptobj.empty();
                    subconobj.empty();
                    var str = "<option value='{0}'>{1}</option>";
                    for (var i = 0; i < obj.length; i++) {
                        deptobj.append($.format(str, obj[i].FieldName, obj[i].FieldDispName));
                        subconobj.append($.format(str, obj[i].FieldName, obj[i].FieldDispName));
                    }
                }
            },
            error: function (e)
            { }
        })
        //清除原有条件
        var subID = parseInt($('#currentSubid').val());
        for (var i = subID; i > 0; i--) {
            $('#subCondition' + i).remove();
            $('#currentSubid').attr("value", i - 1);
        }
    }
    function saveSearch() {
        //if ($("#docList").html() == "")
        //{
        //    messageAlert("请先检索数据！");
        //    return;
        //}
        copyContion();
        $.ajax({
            type: "POST",
            url: timestamp("@Html.Raw(Url.Action("SaveQuery", "Admin_Topic"))"),
            data: $("#formsubmit").serialize(),
            beforeSend: function () { $("#loading").show(); },
            success: function (msg) {
                messageAlert("保存成功！");
                $("#loading").hide();
            },
            error: function (e)
            { $("#loading").hide(); }
        })

    }
    function backlist() {
        ajaxLoad('initload', "@Html.Raw(Url.Action("CategoryDataList", "Admin_Topic"))?name=" + escape($("#NodeName").val()) + "&code=" + $("#nodecode").val() + "&navName=" + escape($("#NavName").val()) + "&navCode=" + $("#NavCode").val());
    }
</script>
<!--内容==开始-->
<div class="wrap">

    <div class="wrapR-h">
        <div class="crumbLink mb10">分类导航管理<span>&gt;</span>建立分类<span>&gt;</span>添加记录</div>
        <h3 class='box-h'>分类:@ViewBag.NodeName </h3>
        <input type="hidden" id="NodeName" name="NodeName" value="@ViewBag.NodeName" />
        <div class="f-gp form form-h" style="margin-top: 20px">
            <div class="f-lb">
                <label class="f-label">
                    选择数据库：  
                </label>

            </div>
            <div class="f-ct">
                <select id="DbList" name="DbList" class='f-select span2' onchange="setinfo()" style="width:400px">
                    @foreach (SYS_CMS_DATABASE item in ViewBag.DatabaseList)
                    {
                        if (item.SearchType == 0)
                        {
                            string str = @item.SysID + "_" + @item.DatabaseCode;
                        <option value="@str">@item.DatabaseName</option>
                        }
                    }
                </select>
            </div>
        </div>
    </div>

    <div class="clearfix">
        <form id="formsubmit">
            <div class="f-gp clearfix" id="searchCondition">
                <span class="f-btn">
                    <a href="javascript:addCondition();" class='iconfont iconfont-add'></a>
                    <a href="javascript:delCondition();" class='iconfont iconfont-minus'></a>
                </span>
                <select id="ConditionKey" name="ConditionKey" class='f-select span2'>
                </select>
                <input style="height: 19px;" id="ConditionValue" name="ConditionValue" type="text" value="" class="f-text span4" maxlength="50" />
                <select id="SubConditionQuery" name="SubConditionQuery" class='f-select span1'>
                    <option value="0">精确</option>
                    <option value="2">模糊</option>
                </select>
                <input class="btn btn-m btn-warn-f btn-submit" type="button" value="检索" onclick="search()" />
                <input class="btn btn-m btn-prim-f" type="button" value="返回" onclick="backlist()" />
            </div>
            <input type="hidden" id="beforeQueryValue" name="beforeQueryValue" value="" />
            <input type="hidden" id="beforeConditionValue" name="beforeConditionValue" value="" />
            <input type="hidden" id="beforeConditionKey" name="beforeConditionKey" value="" />
            <input type="hidden" id="beforecheckedCatID" name="beforecheckedCatID" value="" />
            <input type="hidden" id="beforeselectedCatTypeID" name="beforeselectedCatTypeID" value="" />

            <div id="beforeContion" style="display: none"></div>
            <input type="hidden" id="currentSubid" name="currentSubid" value="0" />
            <input type="hidden" id="checkedCatID" name="checkedCatID" value="" />
            <input type="hidden" id="selectedCatTypeID" name="selectedCatTypeID" value="" />
            <input type="hidden" id="pageIndexNow" name="pageIndexNow" value="1" />
            <input type="hidden" id="sortField" name="sortField" value="" />
            <input type="hidden" id="sortFieldBefore" name="sortFieldBefore" value="@ViewBag.SortFiledInit" />
            <input type="hidden" id="sortInit" name="sortInit" value="@ViewBag.SortDescInit" />
            <input type="hidden" id="sortDescAsc" name="sortDescAsc" value="" />
            <input type="hidden" id="listOrabst" name="listOrabst" value="" />
            <input type="hidden" id="dbID" name="dbID" value="0" />
            <input type="hidden" id="dbName" name="dbName" value="" />
            <input type="hidden" id="DBDisplayName" name="DBDisplayName" value="" />
            <input type="hidden" id="nodecode" name="nodecode" value="@ViewBag.NodeSysCode" />
            <input type="hidden" id="NavCode" name="NavCode" value="@ViewBag.NavCode" />
            <input type="hidden" id="NavName" name="NavName" value="@ViewBag.NavName" />
            <input type="hidden" id="SearchFrom" name="SearchFrom" value="Topic" />
            <div class="f-gp clearfix" id="subCondition0" style="display: none">
                <select id="SubConditionType0" name="SubConditionType0" class='f-select span1'>
                    <option value="0">并且</option>
                    <option value="1">或者</option>
                </select>
                <select id="SubConditionKey0" name="SubConditionKey0" class='f-select span2'>
                </select>
                <input id="SubConditionValue0" name="SubConditionValue0" type="text" value="" class="f-text span4">
                <select id="SubConditionQuery0" name="SubConditionQuery0" class='f-select span1'>
                    <option value="0">精确</option>
                    <option value="2">模糊</option>
                </select>
            </div>
        </form>

        <div id="loading" style="display: none; margin-left: 300px; margin-top: 50px; position: absolute">
            <img src="~/Images/loading.gif" width="50" />
        </div>
        <div style="padding-bottom: 30px;">
            <input class="btn btn-m btn-warn-f btn-submit" type="button" value="保存检索条件" onclick="saveSearch()" />
            
        </div>
        <div id="docList"></div>
    </div>

</div>
<!--内容==结束-->

